﻿using Microsoft.Commerce.Proxy.AccountService;

namespace TestWebApplication.CommerceTestDataProvider
{
    public static class CommerceAccountDataProvider
    {
        public static CallerInfo CreateCallerInfo(Identity requester, string accountId)
        {
            CallerInfo ret = new CallerInfo()
            {
                Requester = requester,
                AccountId = accountId,
            };
            return ret;
        }

        public static Identity CreateRandomIdentity()
        {
            // we only create "PUID" identity type here
            Puid puid = Puid.RandomPuid();
            Identity identity = new Identity();
            identity.IdentityType = "PUID";
            identity.IdentityValue = "1688852026958476";

            identity.IdentityProperty = new[]
            {
                new Property
                {
                    Name = "PassportMemberName",
                    Value = "xialin@hotmail-int.com"
                }
            };

            return identity;
        }

        public static Identity CreateIdentity(string puidValue, string passport)
        {
            Puid puid = Puid.RandomPuid();
            Identity identity = new Identity();
            identity.IdentityType = "PUID";
            identity.IdentityValue = puidValue;

            identity.IdentityProperty = new[]
            {
                new Property
                {
                    Name = "PassportMemberName",
                    Value = passport
                }
            };

            return identity;
        }

        public static AccountInfo CreateRandomAccountInfo()
        {
            return new AccountInfo
            {
                PayinInfo = CreatePayinAccountInfo(),
                PayoutInfo = CreatePayoutAccountInfo()
            };
        }

        public static PayoutAccountInfo CreatePayoutAccountInfo()
        {
            return new PayoutAccountInfo
            {
                CountryCode = "US",
                Currency = "USD",
                Locale = "en-US",
                Email = "mil@hotmail.com",
            };
        }

        public static PayinAccountInfo CreatePayinAccountInfo()
        {
            return new PayinAccountInfo
            {
                FriendlyName = "Fake Payin Info",
                CustomerType = CustomerType.Personal,
                CountryCode = "US",
                Currency = "USD",
                Locale = "en-US",
                FirstName = "serend",
                LastName = "lin",
                Email = "aaa@hotmail.com",
                AddressSet = new Address[]
                {
                    CreateRandomAddressInfo()
                },
            };
        }

        private static Address CreateRandomAddressInfo()
        {
            return new Address
            {
                FriendlyName = GlobalRandom.CreateAlphabeticString(10, 21),
                Street1 = GlobalRandom.CreateAlphabeticString(10, 21),
                UnitNumber = GlobalRandom.Next(2000).ToString(),
                City = "NEW YORK",
                District = GlobalRandom.CreateAlphabeticString(10, 21),
                State = "NY",
                CountryCode = "US",
                PostalCode = "10001"
            };
        }
    }
}
